package schedule.way_timer;

import java.util.Timer;
import java.util.TimerTask;

/**
 * 使用Timer和TimerTask创建定时任务
 */
public class TimerScheduleTask {
    public static void main(String[] args) {
        runTask();
    }

    private static int count = 0;

    private static void runTask() {
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                System.out.println("count is:" + count++);
            }
        };

        Timer timer = new Timer();
        timer.scheduleAtFixedRate(task, 0, 1000);
    }
}
